<template>
    
    <a href="/djshow">等级信息显示</a>
    <h2>等级添加</h2>
    <a href="/qyadd">权益添加</a>
    <table class="table">
        <thead>
            <tr>
                <th>等级名称</th>
                <th>
                    <input type="text" v-model="data.dname">
                </th>
            </tr>
            <tr>
                <th>等级状态</th>
                <th>
                    <input type="radio" value="1" name="djzt" v-model="data.djzt">启用
                    <input type="radio" value="2" name="djzt" v-model="data.djzt">禁用
                </th>
            </tr>
            <tr>
                <th>权益</th>
                <th>
                    <select v-model="data.quanyiid">
                        <option value="0">请选择</option>
                        <option v-for="a in xlk" :value="a.qid" >{{ a.qname}}</option>
                    </select>
                </th>
            </tr>
            <tr>
                <th></th>
                <th>
                    <input type="button" value="添加" @click="audd">
                </th>
            </tr>
        </thead>
    </table>
</template>

<script setup lang="ts">
import axios from 'axios';
import { onMounted, ref } from 'vue';
import { useRouter } from 'vue-router';
const router=useRouter()
///下拉框
const xlk=ref([{
    "qid": 0,
    "qname": "",
    "qzt": 0
}])

onMounted(()=>{
    xllkk()
})
const xllkk=()=>{
    axios.get("https://localhost:7090/api/Dj/Qyxlk").then(res=>{
        xlk.value=res.data;
    })
}


const data=ref({
    "did": 0,
  "dname": "",
  "djzt": 0,
  "quanyiid": 0
})

const audd=()=>{
    axios.post("https://localhost:7090/api/Dj/Dadd",data.value).then(res=>{
        if(res.data>0)
    {
        alert('添加成功')
        router.push({path:"/djshow"})
    }
    else
    {
        alert('添加失败')
        return;
    }
    })
}
</script>

<style scoped>

</style>